package com.heima.behavior.controller;

import com.heima.behavior.service.CollectionService;
import com.heima.behavior.service.CommentService;
import com.heima.behavior.service.LikeService;
import com.heima.behavior.service.ReadService;
import com.heima.model.behavior.dtos.CollectionDto;
import com.heima.model.behavior.dtos.CommentDto;
import com.heima.model.behavior.dtos.LikeDto;
import com.heima.model.behavior.dtos.ReadDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1")
public class BehaviorsController {
    @Autowired
    LikeService userLikeService;
    /**
     * 用户行为——点赞
     * @return
     */
    @PostMapping("/likes_behavior")
    public ResponseResult likeBehavior(@RequestBody LikeDto dto) {
        return userLikeService.likeBehavior(dto);
    }
    /**
     * 用户行为——收藏
     */
    @Autowired
    CollectionService userCollectionService;
    @PostMapping("/collection_behavior")
    public ResponseResult collectionBehavior(@RequestBody CollectionDto dto) {
        return userCollectionService.collectionBehavior(dto);
    }
    /**
     * 用户行为——阅读
     */
    @Autowired
    ReadService userReadService;
    @PostMapping("/read_behavior")
    public ResponseResult readBehavior(@RequestBody ReadDto dto) {
        return userReadService.readBehavior(dto);
    }

    /**
     * 数据回显——收藏
     */
    @PostMapping("/collection/{userId}/{articleId}")
    public Boolean isCollection(@PathVariable("userId") int userId, @PathVariable("articleId") Long articleId){
        return userCollectionService.isCollection(userId,articleId);
    }

    /**
     * 数据回显——点赞
     */
    @PostMapping("/like/{userId}/{articleId}")
    public Boolean isLike(@PathVariable("userId") int userId, @PathVariable("articleId") Long articleId){
        return userLikeService.isLike(userId,articleId);
    }

}
